package com.pda.gongpin.ui.abnormalcheck;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.pda.gongpin.R;
import com.pda.gongpin.adapter.ManifestAdapter;
import com.pda.gongpin.bean.ManifestBean;
import com.pda.gongpin.contract.ManifestContract;
import com.pda.gongpin.event.NoEventBean;
import com.pda.gongpin.presenter.ManifestPresenter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.wangshen.base.ui.mvp.base.ui.BaseMvpFragment;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class ManifestFragment extends BaseMvpFragment<ManifestPresenter> implements ManifestContract.View {
    @BindView(R.id.rv_content)
    RecyclerView rvContent;
    @BindView(R.id.smart)
    SmartRefreshLayout smart;
    ManifestAdapter manifestAdapter;
    @Override
    public ManifestPresenter getPresenter() {
        return new ManifestPresenter();
    }

    @Override
    public int getViewId() {
        return R.layout.fragment_list;
    }

    @Override
    public void initView() {
        smart.setEnableLoadMore(false);
        smart.setEnableRefresh(false);
        manifestAdapter=new ManifestAdapter(R.layout.item_manifest,new ArrayList<>());
        rvContent.setAdapter(manifestAdapter);
        presenter.abnormalDataList();
    }

    @Override
    public void initLinsenterner() {
        manifestAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                EventBus.getDefault().post(new NoEventBean(manifestAdapter.getData().get(position).getOriginOrderNum()));
            }
        });
    }

    @Override
    public void getData() {

    }

    @Override
    public void setList(List<ManifestBean> list) {
        manifestAdapter.setNewInstance(list);
    }
}
